
   		// 扩展API加载完毕后调用onPlusReady回调函数 
   		document.addEventListener( "plusready", plusReady, false );
   		// 扩展API加载完毕，现在可以正常调用扩展API 
		
	
		
		function plusReady(){  
		   cmr = plus.camera.getCamera(); //全局变量

		   console.log("API插件加载完毕！");
		}
		
		
		var file_path ='/storage/emulated/0/Pictures/'; //文件名变量

		var fixed;										//文件名常量

		// 拍照
		function captureImage(){
			var time_info = new Date().getTime().toString();
			var res = cmr.supportedImageResolutions[0];
			var fmt = cmr.supportedImageFormats[0];
			console.log("Resolution: "+res+", Format: "+fmt);
			
			cmr.captureImage( function( path ){
			
					
					plus.nativeUI.toast("拍摄成功！" + path);
					
					fixed = file_path+time_info+ ".jpg";
				},
				function( error ) {
					alert("拍照取消");
			
				},
				{resolution:res,format:fmt,filename:file_path +time_info+ ".jpg"}
		
			);
		}
		
		function classify(){
			var classify_target = prompt("请输入分组名称", "张连臣");
			if (classify_target != null) {
				file_path = '/storage/emulated/0/Pictures/'+classify_target;
				window.alert("设置成功！");
			    document.getElementById("demo").innerHTML = "当前分组:" + classify_target;
			}
		}
		
		function openFile() {
				var pname;
				if (plus.device.vendor.indexOf("Xiaomi")!=-1){
					console.log("识别为小米手机");
					pname = 'com.miui.gallery'
				}
				if (fixed){
					plus.runtime.openFile( fixed,{pname:pname}, function(error){
						plus.nativeUI.toast("打开文件失败" + error);
							} );
						}
				else {
					console.log("请先拍照!",file_path);
				}
			}
